<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../plugins/vue.min.js"></script>
</head>
<body>
    <div id="box">
    <navbar>
        <!-- 在box下面,当然可以访问到isShow -->
        <button @click="isShow = !isShow">出现抽屉</button>
    </navbar>
    <!-- 侧边栏 -->
    <siderbar v-show="isShow"></siderbar>
  

    </div>
  
    <script>
        Vue.component("navbar",{
            template:`<div style="width: 100%;height: 150px;border: 3px solid;">
                <slot></slot>
                </div>
            `
        }) 
        Vue.component("siderbar",{
            template:` <ul>
                 <li>sadfa</li>
                 <li>fasd</li>
                    </ul>
            `
        }) 
        // 根组件
        new Vue({
            el:"#box",
            data:{
                isShow:false
            }
        })
    </script>
</body>
</html>